<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="../../static/admin/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/admin.css"/>
</head>
<body>
<div class="layui-tab page-content-wrap">
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form"  style="width: 90%;padding-top: 20px;">
                {% csrf_token %}
                <div class="layui-form-item">
                    <label class="layui-form-label">问题简述：</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" lay-verify="title" placeholder="问题简述" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" pane="">
                    <label class="layui-form-label">严重程度：</label>
                    <div class="layui-input-block">
                        <input type="radio" name="urgent" value="low" title="低" checked="">
                        <input type="radio" name="urgent" value="centre" title="中">
                        <input type="radio" name="urgent" value="high" title="高">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">详细描述：</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入详细描述内容" name="remark" lay-verify="remark"  class="layui-textarea" style="min-height: 200px;"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="adminInfo" style="margin-top: 30px">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="../../static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/js/jquery.cookie.js"></script>

<script>
    layui.use(['form','element'], function() {
        var form = layui.form();
        form.verify({
            title: function(value){
                if(value.length < 1){
                    return '请填写问题简述';
                }else if(value.length > 32)
                    return '问题简述不能超过32个字符'
            }
            ,remark: function(value){
                if(value.length < 1){
                    return '请填写问题描述';
                }else if (value.length > 256){
                     return '问题描述的长度不能超过256个字符';
                }
            }
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });
        form.on('submit(adminInfo)', function(data){
            var index = layer.load(2, {shade: [0.2, '#5B5B5B']});
            $.ajax({
                url: 'creat_feedback.html',
                type: 'POST',
                data:{'key': 'creat_feedback','base':data.field},
                headers:{'X-CSRFtoken':$.cookie('csrftoken')},
                success: function (base) {
                    if (base == 'true'){
                        layer.msg('提交问题成功！', {icon: 1});
                        //下面为跳出iframe框架的页面跳转
                        setTimeout("window.parent.location.reload();", 2000 )
                    } else {
                        layer.close(index);
                        layer.msg('系统错误，请联系系统管理员！', {icon: 2});
                    }
                }
            })
            return false;
        })
    })
</script>
</body>
</html>